﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;

namespace Application.Services
{
    public interface IJWTService
    {
        /// <summary>
        /// 生成token
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="userName"></param>
        /// <param name="roles"></param>
        /// <returns></returns>
        string GenerateToken(string userId, string userName, ICollection<string> roles);

        /// <summary>
        /// 验证token
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        ClaimsPrincipal? ValidateToken(string token);

        /// <summary>
        /// 通过 ClaimsPrincipal 获取用户Id
        /// </summary>
        /// <param name="principal"></param>
        /// <returns></returns>
        string GetUserId(ClaimsPrincipal principal);

        /// <summary>
        /// 通过 ClaimsPrincipal 获取用户名称
        /// </summary>
        /// <param name="principal"></param>
        /// <returns></returns>
        string GetUserName(ClaimsPrincipal principal);

        /// <summary>
        /// 通过 ClaimsPrincipal 获取用户Id角色权限列表
        /// <param name="principal"></param>
        /// <returns></returns>
        IEnumerable<string> GetRoles(ClaimsPrincipal principal);
    }
}
